﻿using System.Collections.Generic;
using PostSharp.CodeModel;

namespace MicroContainer.CompileTime
{
   /// <summary>
   /// A context shared between all advices.
   /// </summary>
   internal sealed class CodeGenerationContext
   {
      /// <summary>
      /// Gets type declaration of container type.
      /// </summary>
      public TypeDefDeclaration ContainerType { get; private set; }

      /// <summary>
      /// Gets the method used to configure current container.
      /// </summary>
      public MethodDefDeclaration ConfigurationMethod { get; private set; }

      /// <summary>
      /// Gets a dictionary of type mappings.
      /// </summary>
      public IDictionary<TypeMappingKey, TypeMappingDef> TypeMappings { get; private set; }

      /// <summary>
      /// Creates new <see cref="CodeGenerationContext"/> instance.
      /// </summary>
      /// <param name="containerType">Container type declaration.</param>
      /// <param name="configMethod">The method used to configure current container.</param>
      /// <param name="mappings">Type mappings.</param>
      public CodeGenerationContext(TypeDefDeclaration containerType, MethodDefDeclaration configMethod, IDictionary<TypeMappingKey, TypeMappingDef> mappings)
      {
         TypeMappings = mappings;
         ConfigurationMethod = configMethod;
         ContainerType = containerType;
      }
   }
}
